﻿using BrightSword.LightSaber;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Test.LightSaber
{
    /// <summary>
    ///This is a test class for Parser_TokenizerTest and is intended
    ///to contain all Parser_TokenizerTest Unit Tests
    ///</summary>
    [TestClass]
    public class ParserTokenizerTest
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        /// <summary>
        ///A test for IsValidNumber
        ///</summary>
        [TestMethod]
        public void IsValidNumberTest()
        {
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("0.0"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("0"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("100"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("100.0"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("3.1415"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("+100.99"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("-100.99"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("-1.04E-03"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("-1.04E+03"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("-1.04E3"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("1.04E3"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("1E3"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("1.04E3.5"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("-6.025E26"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("+-1E3"), false);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("3.1.45"), false);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("E100"), false);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("1f"), false);
            Assert.AreEqual(Parser.Tokenizer.IsValidNumber("w"), false);
        }

        /// <summary>
        ///A test for IsValidName
        ///</summary>
        [TestMethod]
        public void IsValidNameTest()
        {
            Assert.AreEqual(Parser.Tokenizer.IsValidName("a"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("Aa"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("aBcd"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("_abcd"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("ab1"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("ab_1_2"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("ab_1_2__"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("__"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("_0b"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("a00"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("hba1c"), true);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("0"), false);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("+ab"), false);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("1f"), false);
            Assert.AreEqual(Parser.Tokenizer.IsValidName("00a"), false);
        }
    }
}